package com.rc.web.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.rc.pojo.po.Poster;
import com.rc.web.mapper.PosterMapper;
import com.rc.web.service.PosterService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service
public class PosterServiceImpl extends ServiceImpl<PosterMapper, Poster> implements PosterService {

    @Override
    public void saveImage(String newUrl) {
        Poster poster = new Poster();
        poster.setImages(newUrl);
        save(poster);
    }

    @Override
    public List<String> getAllImages() {
        // 查询所有Poster记录
        List<Poster> posters = list();
        // 提取图片URL
        return posters.stream()
                .map(Poster::getImages)
                .collect(Collectors.toList());
    }
}
